<?php

namespace App\Models\Open;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Rennokki\QueryCache\Traits\QueryCacheable;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;

class AppType extends Model implements Sortable
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    use SortableTrait;

    protected $table = 'app_types';

    use QueryCacheable;

    protected $cacheFor = 3600;
    protected static $flushCacheOnUpdate = true;

    protected $fillable = [
        'platform_id', 'name', 'aliasname', 'description', 'order',
    ];

    protected $sortable = [
        'order_column_name' => 'order',
        'sort_when_creating' => true,
    ];

    public function platform(): BelongsTo
    {
        return $this->belongsTo('App\Models\Open\Platform');
    }

}
